﻿using System.Windows.Controls;
using System;
using Client.Processes;
using Client.ViewModels;
using Client.Views;

namespace Client.Commands
{
    public class LoadMovieCommand : BaseCommand
    {
        private ReadMovie load;

        public LoadMovieCommand(ReadMovie load)
        {
            this.load = load;
        }

        public override bool CanExecute(object parameter)
        {
            var viewModel = (parameter as WorkspaceViewModel);

            if (viewModel == null)
                return false;

            return viewModel.IsListView && viewModel.MovieItem != null;
        }

        /// <summary>
        /// Movie wird aus Datenbank geladen
        /// </summary>
        /// <param name="parameter">MovieName</param>
        /// <returns></returns>
        public override void Execute(object parameter)
        {
            load.Process((parameter as WorkspaceViewModel).MovieItem.Id);
        }
    }
}
